﻿using System;
using System.Collections.Generic;
using TSites.Offices;

namespace TSites.Service.Entities
{
	public class Company
	{
		public string ID { get; set; }
		public string TaxCode { get; set; }
		public string VietnamesName { get; set; }
		public string EnglishName { get; set; }
		public List<string> ContractNos { get; set; }
		public string SelectedContractNo { get; set; } // for export word
		public string VietnamesPosition { get; set; }
		public string EnglishPosition { get; set; }
		public string RepresentedBy { get; set; }
		public string Phone { get; set; }
		public string Fax { get; set; }
		public string VietnamesAddress { get; set; }
		public string EnglishAddress { get; set; }

		public void AddBookMarks(Dictionary<string, object> bookmarkHash, int language)
		{
			bookmarkHash = bookmarkHash ?? new Dictionary<string, object>();

			string prefix = "Client";
			string name, representedBy, position, telephoneNo, fax, address, taxCode, contractNo;

			representedBy = RepresentedBy;
			telephoneNo = Phone;
			fax = Fax;
			taxCode = TaxCode;
			contractNo = SelectedContractNo;
			if (language == 0) // Vietnames
			{
				name = VietnamesName;
				position = VietnamesPosition;
				address = VietnamesAddress;
			}
			else // English
			{
				name = EnglishName;
				position = EnglishPosition;
				address = EnglishAddress;
			}

			// add to hash
			bookmarkHash.Add(prefix + "Name", name);
			bookmarkHash.Add(prefix + "Name1", name);
			bookmarkHash.Add(prefix + "Name2", name);
			bookmarkHash.Add(prefix + "Name3", name);

			bookmarkHash.Add(prefix + "RepresentedBy", representedBy);
			bookmarkHash.Add(prefix + "RepresentedBy1", representedBy);

			bookmarkHash.Add(prefix + "Position", position);
			bookmarkHash.Add(prefix + "Position1", position);

			bookmarkHash.Add(prefix + "TelephoneNo", telephoneNo);
			bookmarkHash.Add(prefix + "Fax", fax);
			bookmarkHash.Add(prefix + "Address", address);
			bookmarkHash.Add(prefix + "TaxCode", taxCode);
			bookmarkHash.Add(prefix + "ContractNo", contractNo);
		} 

		public void ExportContract(string templatePath, Dictionary<string, object> templateParams,
			string filePath = null, bool isVisible = false, string printerName = null)
		{
			WordObject.ExportAndPrint(templatePath, templateParams, filePath, isVisible, printerName);
		}
	}
}
